import React from 'react'
import './App.css'
import TarbarSelector from './components/Antd/TarbarSelector'
import { useEffect } from 'react'
import { useMyDispatch } from './store'
import { setIP } from './store/modules/codeall'

function App() {
  const dispatch = useMyDispatch()
  useEffect(() => {
    async function getIP() {
      try {
        const response = await fetch('http://localhost:3001/ip')
        const date = await response.json()
        const ip = date.wlanAddress || 'localhost'
        console.log(ip)
        dispatch(setIP(ip))
      } catch (error) {
        console.log(error)
        dispatch(setIP('localhost'))
      }
    }
    getIP()
  }, [dispatch])
  return (
    <div className="App">
      <TarbarSelector />
    </div>
  )
}

export default App
